
#include "StateShop.h"
#include "StateShopAnimals.h"
//#include "StateShopUpgrades.h"
//#include "StateShopPowerUps.h"
#include "StateCoinsPopUp.h"

#include "StateMainMenu.h"
#include "StateManager.h"
#include "InputManager.h"
#include "AudioUtils.h"
#include "ProgressManager.h"

void StateShop::loadContent()
{
    StateShopCommon::loadContent();
    
    m_oTitleText->setText("Shop");
    
    m_oBabiesIcon = new RenderableEntity("babies", Vector2(320, 650));
    m_oBabiesIcon->setCentered();
    m_oBabiesIcon->changeColorWhenClicked(true);
    m_oBabiesIcon->setupButton(Vector2(0.55f, 0.55f));
    
    m_oBabiesRibbon = new RenderableEntity("MENU_0009_ribbon", Vector2(320, 530));
    m_oBabiesRibbon->setScale(Vector2(0.5f, 0.5f));
    m_oBabiesRibbon->setCentered();
    
    m_oBabiesText = new TextEntity("Babies", FONT_NAME, 32, Vector2(320, 540), 1, 1);
    m_oBabiesText->setCentered();
    m_oBabiesText->setColor(COLOR_PINK_TEXT);
    m_oBabiesText->setShadow();
    
    
    m_oUpgradesIcon = new RenderableEntity("upgrades", Vector2(170, 350));
    m_oUpgradesIcon->setCentered();
    m_oUpgradesIcon->changeColorWhenClicked(true);
    m_oUpgradesIcon->setupButton(Vector2(0.55f, 0.55f));
    
    m_oUpgradesRibbon = new RenderableEntity("MENU_0009_ribbon", Vector2(170, 230));
    m_oUpgradesRibbon->setScale(Vector2(0.5f, 0.5f));
    m_oUpgradesRibbon->setCentered();
    
    m_oUpgradesText = new TextEntity("Upgrades", FONT_NAME, 32, Vector2(170, 240), 1, 1);
    m_oUpgradesText->setCentered();
    m_oUpgradesText->setColor(COLOR_PINK_TEXT);
    m_oUpgradesText->setShadow();
    
    
    m_oPowerUpsIcon = new RenderableEntity("powerups", Vector2(470, 350));
    m_oPowerUpsIcon->setCentered();
    m_oPowerUpsIcon->changeColorWhenClicked(true);
    m_oPowerUpsIcon->setupButton(Vector2(0.55f, 0.55f));
    
    m_oPowerUpsRibbon = new RenderableEntity("MENU_0009_ribbon", Vector2(470, 230));
    m_oPowerUpsRibbon->setScale(Vector2(0.5f, 0.5f));
    m_oPowerUpsRibbon->setCentered();
    
    m_oPowerUpsText = new TextEntity("PowerUps", FONT_NAME, 30, Vector2(470, 240), 1, 1);
    m_oPowerUpsText->setCentered();
    m_oPowerUpsText->setColor(COLOR_PINK_TEXT);    
    m_oPowerUpsText->setShadow();
    
    
    m_oEnter->addInEffect(m_oBabiesIcon);
    m_oEnter->addInEffect(m_oBabiesRibbon);
    m_oEnter->addInEffect(m_oBabiesText);
    m_oEnter->addInEffect(m_oUpgradesIcon);
    m_oEnter->addInEffect(m_oUpgradesRibbon);
    m_oEnter->addInEffect(m_oUpgradesText);
    m_oEnter->addInEffect(m_oPowerUpsIcon);
    m_oEnter->addInEffect(m_oPowerUpsRibbon);
    m_oEnter->addInEffect(m_oPowerUpsText);

    m_oExit->addOutEffect(m_oBabiesIcon);
    m_oExit->addOutEffect(m_oBabiesRibbon);
    m_oExit->addOutEffect(m_oBabiesText);
    m_oExit->addOutEffect(m_oUpgradesIcon);
    m_oExit->addOutEffect(m_oUpgradesRibbon);
    m_oExit->addOutEffect(m_oUpgradesText);
    m_oExit->addOutEffect(m_oPowerUpsIcon);
    m_oExit->addOutEffect(m_oPowerUpsRibbon);
    m_oExit->addOutEffect(m_oPowerUpsText);
}

void StateShop::unloadContent()
{
    StateShopCommon::unloadContent();
}

void StateShop::activated()
{
    StateShopCommon::activated();
}

void StateShop::enter()
{
    StateShopCommon::enter();
}

void StateShop::update(float dt)
{
    StateShopCommon::update(dt);
    
    switch(m_eState)
    {
        case SHOP_IDLE:
            
            m_oBabiesIcon->update();
            m_oUpgradesIcon->update();
            m_oPowerUpsIcon->update();
            
            if(m_oBabiesIcon->isClicked())
            {
                m_oExit->start(true);
                m_eState = SHOP_EXIT;
                m_oNextState = &StateShopAnimals::instance();
            }
            /*
            else if(m_oUpgradesIcon->isClicked())
            {
                m_oExit->start(true);
                m_eState = SHOP_EXIT;
                m_oNextState = &StateShopUpgrades::instance();
            }
            else if(m_oPowerUpsIcon->isClicked())
            {
                m_oExit->start(true);
                m_eState = SHOP_EXIT;
                m_oNextState = &StateShopPowerUps::instance();
            }
            */
            break;
            
        default:
            break;
    }
}

void StateShop::render()
{
    StateShopCommon::render();
    
    m_oBabiesIcon->render();
    m_oBabiesRibbon->render();
    m_oBabiesText->render();
    
    m_oUpgradesIcon->render();
    m_oUpgradesRibbon->render();
    m_oUpgradesText->render();
    
    m_oPowerUpsIcon->render();
    m_oPowerUpsRibbon->render();
    m_oPowerUpsText->render();
}

void StateShop::exit()
{
    StateShopCommon::exit();
}

void StateShop::setBackState()
{
    m_oNextState = &StateMainMenu::instance();
}
